<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>

<body>
	<script>
	function timeElapse(date){
		var current = new Date();
		alert(current.getFullYear());
		alert(current.getMonth());
		alert(current.getDate());
		var seconds = (Date.parse(current) - Date.parse(date)) / 1000;
		var days = Math.floor(seconds / (3600 * 24));
		seconds = seconds % (3600 * 24);
		var hours = Math.floor(seconds / 3600);
		if (hours < 10) {
			hours = "0" + hours;
		}
		seconds = seconds % 3600;
		var minutes = Math.floor(seconds / 60);
		if (minutes < 10) {
			minutes = "0" + minutes;
		}
		seconds = seconds % 60;
		if (seconds < 10) {
			seconds = "0" + seconds;
		}
		var result = days + " " + hours + " " + minutes + " " + seconds + "";
		alert(result);
	}
	var together = new Date();
	together.setFullYear(2016, 2, 24); 			//时间年月日
	together.setHours(19);						//小时
	together.setMinutes(40);					//分钟
	together.setSeconds(0);					//秒前一位
	together.setMilliseconds(0);				//秒第二位
	timeElapse(together);
	</script>
</body>
</html>
